//
//  ChartsDetailController.m
//  CaiPiao
//
//  Created by l wb on 2018/5/19.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ChartsDetailController.h"
#import "ForecastDetailCell.h"
@interface ChartsDetailController ()<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UIImageView *headImg;
@property (weak, nonatomic) IBOutlet UILabel *nameLab;
@property (weak, nonatomic) IBOutlet UILabel *labelOne;
@property (weak, nonatomic) IBOutlet UILabel *labTwo;
@property (weak, nonatomic) IBOutlet UILabel *labThree;

@property (strong, nonatomic) NSArray* dataArr;
@end

@implementation ChartsDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"预测详情";
    [self setHeadViewUI];
    self.dataArr = self.modelData.prediction;
    
}
-(void)setHeadViewUI{
    self.headImg.image = [UIImage imageNamed:self.modelData.Grandmaster_avatar];
    self.nameLab.text = self.modelData.Grandmaster_name;
    self.labelOne.text = self.modelData.type;
    self.labTwo.text = self.modelData.Success_rate;
    self.labThree.text = self.modelData.lian_z;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArr.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 90;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSDictionary *modelDic = self.dataArr[indexPath.row];
    ForecastDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ForecastDetailCell"];

    cell.titleLabel.text = modelDic[@"Species"];
    cell.dateLabel.text = [NSString stringWithFormat:@"%@  %@",modelDic[@"Issue"],modelDic[@"date"]] ;
    cell.titleImageView.image = [UIImage imageNamed:[self getImgNameWithSpecies:modelDic[@"Species"]]];
    [cell setWinNumWith:modelDic[@"winNumber"]];
    if ([modelDic[@"status"] isEqualToString:@"1"]) {
        cell.statusImg.hidden = NO;
    } else {
        cell.statusImg.hidden = YES;
    }
    
    return cell;
}
-(NSString *)getImgNameWithSpecies:(NSString *)str{
    if ([str isEqualToString:@"福彩3D"]) {
        return @"f-福彩3D";
    }else if ([str isEqualToString:@"双色球"]){
        return @"f-双色球";
    }else if ([str isEqualToString:@"大乐透"]){
        return @"f-大乐透";
    }
    else{
        return @"f-双色球";
    }
    
}


@end
